import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

export const constantRoutes = [
  {
    path: '/home',
    name: 'home',
    component:  () => import('@/views/home'),
  },
  {
    path: '/form',
    name: 'form',
    component:  () => import('@/views/Form'),
  },
  {
    path: '/projectlist',
    name: 'projectlist',
    component:  () => import('@/views/ProjectList'),
  },
  {
    path: '/',
    name: 'login',
    component:  () => import('@/views/login'),
  }
]
const createRouter = () => new Router({
  mode: 'hash', // require service support

  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router